#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <sys/wait.h>
#include <sys/types.h>

int main(){

 //   while(1){
 //   printf("1111   %d\n",getpid());
 //   sleep(1);
//  }
  
  //int a=0;
  //scanf("%d",&a);
  //printf("%d\n",a);

  pid_t id=fork();

    if(id==0)
    {
      //child
      int count=5;

      while(count){
        printf("I am child,pid: %d,ppid: %d\n",getpid(),getppid());
        sleep(1);
        count--;
      }
         exit(0);//让子进程直接退出
    }
    int count=10;
  //father  
    while(1)
    {
      count--;
      printf("I am fathar,pid: %d,ppid: %d\n",getpid(),getppid());
      sleep(1);
    }
  
     wait(NULL);
     printf("father wait child done....\n");
     sleep(5);


  return 0;
}
